import { AutoFeedCheckBoxSprite } from "../../autoFeed/AutoFeedCheckBoxSprite";
import { ObjCreate } from "../../common/ObjCreate";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { ItemData } from "../../../resource/info/ItemData";
import { MountConfig } from "../../../resource/MountConfig";
import { Language } from "../../../../../extend/language/Language";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
type int = number;
//class MountStartsSingleTarget
    
    export  class MountStartsSingleTarget extends AutoFeedCheckBoxSprite
    {
        constructor()
        {
            super();
            this._bmArr = [];
            this.initView();
            return;
        }

        /* internal  */initView(): void
        {
            this._statrsSp = new AutoFeedCheckBoxSprite();
            addChild(this._statrsSp);
            this._mainTx = ObjCreate.createTextField("", 10, 8, 70, 25, this);
            this._isCurTx = ObjCreate.createTextField("", this._mainTx.x + this._mainTx.width, 10, 80, 20, this);
            this._isOpenTx = ObjCreate.createTextField("", 10, 74, 40, 20, this);
            this._decTx = ObjCreate.createTextField("", 10, 92, 180, 25, this);
            this._addVlueTx = ObjCreate.createTextField("", 10, 113, 180, 25, this);
            LoaderHelp.addResCallBack(ResFileConst.mountStarts, this.onLoadBmResource);
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._loaded = true;
            if (this._bmArr.length == 0) 
            {
                this.changeBm();
            }
            return;
        }

        public setData(arg1: ItemData, arg2: int, arg3: Boolean, arg4: Boolean): void
        {
            this._mountIdata = arg1;
            this._starsLv = arg2;
            this._isCur = arg3;
            this._isOpen = arg4;
            if (this._mountIdata) 
            {
                this.upDateSharps();
            }
            return;
        }

        /* internal  */upDateSharps(): void
        {
            while (this._statrsSp.numChildren > 0) 
            {
                this._statrsSp.removeChildAt(0);
            }
            this._bmArr = [];
            this._startAmount = MountConfig.instance.getMountStarts(this._starsLv + 1).starAmount;
            this._curTarget = this._mountIdata.itemExInfo.m_stTa[this._starsLv];
            if (this._isCur) 
            {
                this._sharpType = this._curTarget;
                this._isCurTx.htmlText = "<font color=\'#ffffff\'>（" + Language.getString(70237) + "）</font>";
            }
            else 
            {
                this._sharpType = this._curTarget + 1;
                this._isCurTx.htmlText = "<font color=\'#ffffff\'>（" + Language.getString(70238) + "）</font>";
            }
            if (this._isOpen) 
            {
                this._isOpenTx.htmlText = "<font color=\'#60e71e\'>" + Language.getString(70239) + "</font>";
            }
            else 
            {
                this._isOpenTx.htmlText = "<font color=\'#ff0000\'>" + Language.getString(70240) + "</font>";
            }
            if (this._sharpType <= 3) 
            {
                this._bmStr = ImagesConst.mountStartsBuleStart;
                if (this._isOpen) 
                {
                    this._mainTx.htmlText = "<font size=\'14\' color=\'#00a2ff\'><strong>" + Language.getString(70241) + " </strong> </font>";
                    this._decTx.htmlText = "<font color=\'#FF7902\'>" + Language.getString(70244) + "</font>";
                }
                else 
                {
                    this._mainTx.htmlText = "<font size=\'14\' color=\'#888888\'><strong>" + Language.getString(70241) + " </strong> </font>";
                    this._decTx.htmlText = "<font color=\'#888888\'>" + Language.getString(70244) + "</font>";
                }
                this._factor = MountConfig.instance.getLvColor2Factor((this._starsLv + 1).toString() + "_" + 3) / 10;
            }
            else if (this._sharpType != 4) 
            {
                if (this._sharpType != 5) 
                {
                    this._bmStr = ImagesConst.mountStartsGoldStart;
                    if (this._isOpen) 
                    {
                        this._mainTx.htmlText = "<font size=\'14\' color=\'#F6A660\'><strong>" + Language.getString(70284) + " </strong> </font>";
                        this._decTx.htmlText = "<font color=\'#F6A660\'>" + Language.getString(70285) + "</font>";
                    }
                    else 
                    {
                        this._mainTx.htmlText = "<font size=\'14\' color=\'#888888\'><strong>" + Language.getString(70284) + " </strong> </font>";
                        this._decTx.htmlText = "<font color=\'#888888\'>" + Language.getString(70285) + "</font>";
                    }
                    this._factor = MountConfig.instance.getLvColor2Factor((this._starsLv + 1).toString() + "_" + 6) / 10;
                }
                else 
                {
                    this._bmStr = ImagesConst.mountStartsOrangeStart;
                    if (this._isOpen) 
                    {
                        this._mainTx.htmlText = "<font size=\'14\' color=\'#FF7902\'><strong>" + Language.getString(70243) + " </strong> </font>";
                        this._decTx.htmlText = "<font color=\'#FF7902\'>" + Language.getString(70246) + "</font>";
                    }
                    else 
                    {
                        this._mainTx.htmlText = "<font size=\'14\' color=\'#888888\'><strong>" + Language.getString(70243) + " </strong> </font>";
                        this._decTx.htmlText = "<font color=\'#888888\'>" + Language.getString(70246) + "</font>";
                    }
                    this._factor = MountConfig.instance.getLvColor2Factor((this._starsLv + 1).toString() + "_" + 5) / 10;
                }
            }
            else 
            {
                this._bmStr = ImagesConst.mountStartsPurpleStart;
                if (this._isOpen) 
                {
                    this._mainTx.htmlText = "<font size=\'14\' color=\'#ff00ff\'><strong>" + Language.getString(70242) + " </strong> </font>";
                    this._decTx.htmlText = "<font color=\'#FF7902\'>" + Language.getString(70245) + "</font>";
                }
                else 
                {
                    this._mainTx.htmlText = "<font size=\'14\' color=\'#888888\'><strong>" + Language.getString(70242) + " </strong> </font>";
                    this._decTx.htmlText = "<font color=\'#888888\'>" + Language.getString(70245) + "</font>";
                }
                this._factor = MountConfig.instance.getLvColor2Factor((this._starsLv + 1).toString() + "_" + 4) / 10;
            }
            if (this._isOpen) 
            {
                this._addVlueTx.htmlText = "<font color=\'#60e71e\'>" + Language.getString(70247) + this._factor + "%" + "</font>";
            }
            else 
            {
                this._addVlueTx.htmlText = "<font color=\'#888888\'>" + Language.getString(70247) + this._factor + "%" + "</font>";
            }
            if (this._loaded) 
            {
                this.changeBm();
            }
            return;
        }

        /* internal  */changeBm(): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < this._startAmount) 
            {
                loc1 = ObjCreate.createBitmap("", loc2 % 5 * 32, Math.floor(loc2 / 5) * 34, this._statrsSp);
                loc1.bitmapData = GlobalClass.getBitmapData(this._bmStr);
                ++loc2;
            }
            this.resizeStation();
            return;
        }

        /* internal  */resizeStation(): void
        {
            this._mainTx.x = 10;
            this._mainTx.y = 4;
            this._isCurTx.x = this._mainTx.x + this._mainTx.width + 2;
            this._isCurTx.y = this._mainTx.y + 2;
            this._statrsSp.x = this._mainTx.x;
            this._statrsSp.y = 30;
            if (this._startAmount > 5) 
            {
                this._statrsSp.height = 68;
            }
            else 
            {
                this._statrsSp.height = 34;
            }
            this._isOpenTx.x = this._mainTx.x;
            this._isOpenTx.y = this._statrsSp.y + this._statrsSp.height + 2;
            this._decTx.x = this._mainTx.x;
            this._decTx.y = this._isOpenTx.y + this._isOpenTx.height + 2;
            this._addVlueTx.x = this._mainTx.x;
            this._addVlueTx.y = this._decTx.y + this._decTx.height;
            return;
        }

        public /* override */ get height(): number
        {
            this.resizeStation();
            return this._addVlueTx.y + this._addVlueTx.height;
        }

        /* internal */ /* var */_mountIdata: ItemData;

        /* internal */ /* var */_starsLv: int;

        /* internal */ /* var */_isCur: Boolean;

        /* internal */ /* var */_isOpen: Boolean;

        /* internal */ /* var */_statrsSp: AutoFeedCheckBoxSprite;

        /* internal */ /* var */_startAmount: int;

        /* internal */ /* var */_curTarget: int;

        /* internal */ /* var */_sharpType: int;

        /* internal */ /* var */_bmArr: Array<any>;

        /* internal */ /* var */_bmStr: string="";

        /* internal */ /* var */_loaded: Boolean;

        /* internal */ /* var */_mainTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_isCurTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_isOpenTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_decTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_addVlueTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_factor: number;
    }
